<?php
namespace model;

/**
 * cechy produktów z danej kategorii
 *
 * @author Damian
 */
class TblCategoryFeature extends Model{
    /**
     * @readwrite
     * @column
     * @primary
     * @type int
     */
    public $CategoryFeatureID;
    const ID="CategoryFeatureID";
    /**
     *
     * @readwrite
     */
    public $CategoryID;
    const CATEGORY_ID="CategoryID";
    
    /**
     * @readwrite
     * @column
     * @type varchar
     * @length 50
     * @validate required, max(50)
     */
    public $Name;
    const NAME="Name";
    
    /**
     * @readwrite
     */
    public $ShopID;
    const SHOP_ID="ShopID";
    
    public function getAllByCategory(TblCategory $category){
         $IDs = $category->getAllIds();
         $Criteria = new \model\Criteria();
         $Criteria->from(\model\TblCategoryFeature::getModel()->getTable())
                 ->where(\model\TblCategoryFeature::SHOP_ID,"=" , $category->ShopID)
                 ->in(\model\TblCategoryFeature::CATEGORY_ID, $IDs,false," and ");
         return \model\TblCategoryFeature::getModel()->all($Criteria);
    }
    
}
